package com.sjw.smarturl.entity.vo;

import com.sjw.smarturl.enums.StatusEnum;

/**
 * @author sjw
 * @className ResultMode
 * @date 2020/8/24 13:53
 * @description: TODO
 */
public class ResultMode<T> {
    private T result;
    private int statusCode;
    private String message;

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static ResultMode okInstance(Object result) {
        return new ResultMode(result, 1000, "成功");
    }

    public static ResultMode errorInstance(StatusEnum statusEnum) {
        return new ResultMode(null, statusEnum.getCode(), statusEnum.getMsg());
    }

    public static ResultMode errorInstance(int statusCode, String mesage) {
        return new ResultMode(null, statusCode, mesage);
    }

    public ResultMode(T result, int statusCode, String message) {
        this.result = result;
        this.statusCode = statusCode;
        this.message = message;
    }
}
